//
//  CouponListCell.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/16.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "CouponListCell.h"
@interface CouponListCell()

@property(nonatomic,strong)UILabel *title;
@property(nonatomic,strong)UILabel *price;
@property(nonatomic,strong)UILabel *qty;
@property(nonatomic,strong)UILabel *beginDate;
@property(nonatomic,strong)UILabel *endDate;
@property(nonatomic,strong)UILabel *imageUrl;
@property(nonatomic,strong)UILabel *imageUrlFull;
@property(nonatomic,strong)UILabel *useLimitAmt;
@property(nonatomic,strong)UILabel *lineLabel;

@property(nonatomic,strong)UIButton*share;
@end
@implementation CouponListCell
@synthesize Delegate;
- (void)awakeFromNib {
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
     

    }
    
    return self;
    
}
-(void)createView
{
    UIView *ditu=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 120, 120)];
    ditu.backgroundColor=[UIColor colorWithRed:109/255.0 green:168/255.0 blue:33/255.0 alpha:1.0];
    [self addSubview:ditu];
    
    UIView *ditu1=[[UIView alloc]initWithFrame:CGRectMake(ditu.right, 10, ScreenWidth-140, 120)];
    ditu1.backgroundColor=luseColor;
    [self addSubview:ditu1];
    _price=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 120, 120)];
    _price.font=[UIFont boldSystemFontOfSize:42];
    _price.textColor=[UIColor whiteColor];
    _price.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_price];
    _qty=[[UILabel alloc]initWithFrame:CGRectMake(10, 105, 120, 12)];
    _qty.font=[UIFont boldSystemFontOfSize:9];
    _qty.textColor=[UIColor whiteColor];
    _qty.alpha=0.5;
    _qty.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_qty];
    _title=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 10+43, 150, 16)];
    _title.font=[UIFont boldSystemFontOfSize:16];
    _title.textColor=[UIColor whiteColor];
    _title.textAlignment=NSTextAlignmentRight;
    [self addSubview:_title];
    
    _useLimitAmt=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-220, 10+43+16+6, 170, 16)];
    _useLimitAmt.font=[UIFont boldSystemFontOfSize:14];
    _useLimitAmt.textColor=[UIColor whiteColor];
    _useLimitAmt.alpha=0.8;
    _useLimitAmt.textAlignment=NSTextAlignmentRight;
    [self addSubview:_useLimitAmt];
    _beginDate=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-220, 105, 190, 12)];
    _beginDate.font=[UIFont boldSystemFontOfSize:9];
    _beginDate.textColor=[UIColor whiteColor];
    _beginDate.alpha=0.5;
    _beginDate.textAlignment=NSTextAlignmentRight;
    [self addSubview:_beginDate];
    
    _share=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-70, 10, 60, 60)];
    [_share setBackgroundImage:[UIImage imageNamed: @"fenxiang-youhuiquan"] forState:UIControlStateNormal];
    [_share addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
    _share.tag=self.index.intValue;
    [self addSubview:_share];

   
    UIImageView*dian=[[UIImageView alloc]initWithFrame:CGRectMake(127, 10, 6, 120)];
    dian.image=[UIImage imageNamed:@"youhuiquanxuxian"];
    [self addSubview:dian];

}

-(void)share:(UIButton*)sender{

    NSLog(@"-----%ld",sender.tag);
   [Delegate share:[NSString stringWithFormat:@"%ld",  sender.tag]];


}
-(void)setModel:(CouponListModel *)model
{
    [self createView];
    [self setViewAutoLayout];
    self.price.text=[NSString stringWithFormat:@"%@",  model.price];
    self.title.text=[NSString stringWithFormat:@"%@",  model.title];
    self.qty.text=[NSString stringWithFormat:@"发放数量 %@",model.qty];
    self.useLimitAmt.text=[NSString stringWithFormat:@"用券的最低金额 ¥ %@",model.useLimitAmt];
    NSRange range={0,10};
    NSString* string =[[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",model.beginDate]] substringWithRange:range];
    NSRange range1={0,10};
    NSString* string1 =[[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",model.endDate]] substringWithRange:range1];
    self.beginDate.text=[NSString stringWithFormat:@"有效期 %@~%@",string,string1];

}



-(void)setViewAutoLayout
{
//    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.mas_left).with.offset(15) ;
//        make.height.equalTo(@16);
//        make.top.equalTo(self.mas_top).with.offset(25);
//    }];
//    
//    [self.seximage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.userName.mas_right).with.offset(3);
//        make.width.equalTo(@20);
//        
//        make.height.equalTo(@20);
//        
//        make.top.equalTo(self.mas_top).with.offset(25);
//    }];
//    [self.integral mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.seximage.mas_right).with.offset(15);
//        
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.seximage.mas_centerY) ;
//    }];
//    
//    [self.integral1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.integral.mas_right).with.offset(3);
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.seximage.mas_centerY) ;
//        
//    }];
//    
//    
//    [self.source mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.mas_left).with.offset(15) ;
//        make.height.equalTo(@14);
//        make.top.equalTo(self.userName.mas_bottom).with.offset(15);
//    }];
//    
//    [self.source1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.source.mas_right).with.offset(3);
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.source.mas_centerY) ;
//        
//    }];
//    [self.createDate mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.source1.mas_right).with.offset(15);
//        
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.source1.mas_centerY) ;
//    }];
//    
//    [self.createDate1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.createDate.mas_right).with.offset(3);
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.createDate.mas_centerY) ;
//        
//    }];
//    
//    
//    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.mas_left).with.offset(15) ;
//        make.height.equalTo(@14);
//        make.top.equalTo(self.createDate1.mas_bottom).with.offset(5);
//    }];
//    
//    [self.address1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.address.mas_right).with.offset(3);
//        make.height.equalTo(@14);
//        
//        make.centerY.equalTo(self.address.mas_centerY) ;
//        
//    }];
//    
//    
//    
//    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.mas_left).with.offset(10);
//        make.right.equalTo(self.mas_right).with.offset(-10) ;
//        
//        make.height.equalTo(@1);
//        
//        make.top.equalTo(@108).with.offset(0);
//    }];
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end